class Person{
    //成员变量
    private String name;
    public int age;
    {
        System.out.println("实例代码块");
    }
    public static int count;
    static{
        count = 99;
        System.out.println("静态代码块");
    }

    public Person(){
        //this("nianian",19);//这代表调用一个参数的构造方法
        System.out.println("Person()::不带参数的构造方法");
    }
    public Person(String name){
        this.name = name;
        System.out.println("Person(String)::带一个String类型参数的构造方法");
    }
    public Person(String name, int age){
        this.name = name;
        this.age = age;
        System.out.println("Person(String,int)::带一个String类型和int类型参数的构造方法\"");
    }
    public void setAge(int age){
        this.age = age;
    }
    public int getAge(){
        return age;
    }
    //静态成员变量

    public void setName(String myName){
        name = myName;
    }

    public String getName(){
        return name;
    }
//    public final int size = 10;//存储在对象当中
//    public static final int coun = 99;//存储在方法区

    public void eat(){

        System.out.println(name + "正在吃饭");
    }
    public void print(){
        staticFunc();
        System.out.println("姓名："+ name + " 年龄" + age);
    }

    public static void staticFunc(){
        Person person = new Person();
        person.print();
        //static int size = 0;//erro
        System.out.println("static::func()");
    }
//    public String toString(){
//        return "晒晒太阳";

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
//    }
}


public class TestDemo {
    public static void main(String[] args) {
        new Person().eat();
        new Person().print();
        //没有名字
        System.out.println(new Person());
        System.out.println("=================");
        Person person1 = new Person();
        person1.eat();
        person1.print();
        System.out.println(person1);
    }


    public static void main15(String[] args) {
        System.out.println(Person.count);
    }
    public static void main14(String[] args) {
        Person person = new Person();
        System.out.println("===========");
        Person person1 = new Person();
    }

    public static void main13(String[] args) {
        Person person = new Person();
        System.out.println(person);
    }
    public static void main12(String[] args) {
        Person person = new Person();
        System.out.println("==========");
        Person person2 = new Person("bit");
    }
    public static void main11(String[] args) {
        Person person = new Person();
        person.setName("bit");
        person.setAge(19);
        System.out.println(person.getAge());
        System.out.println(person.getName());
        System.out.println(person);

    }

    public static void main8(String[] args) {
        TestDemo testdemo = new TestDemo();

    }
    public static void main7(String[] args) {
        Person person = new Person();
        person = new Person();
        person = new Person();
        person = new Person();
        person = new Person();
    }

    public static void main4(String[] args) {
        //类方法
        Person.staticFunc();
    }
    public static void main2(String[] args) {
        Person person = new Person();
        person.age = 1;
        System.out.println(person.age);//1

        System.out.println("=================");

        Person person2 = new Person();
        person2.age++;
        System.out.println(person2.age);//1
    }


    public static void main3(String[] args) {
        Person person = new Person();
        person.count = 1;
        System.out.println(person.count);

        System.out.println("=================");

        Person person2 = new Person();
        person2.count++;
        System.out.println(person2.count);
    }

//    public static void main1(String[] args) {
//        Person person = new Person();
//        System.out.println(person.name);
//        System.out.println(person.age);
//        person.eat();
//        person.print();
//        System.out.println("============");
//        Person person1 = new Person();
//        person1.name = "gaobo";
//        person1.age = 19;
//        System.out.println(person1.name);
//        System.out.println(person1.age);
//
//    }
}
